package com.ruoyi.web.controller.community.service;

import java.util.List;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.community.domain.ServiceProblems;
import com.ruoyi.community.service.IServiceProblemsService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 问卷调查Controller
 * 
 * @author 袁现程
 * @date 2021-08-01
 */
@RestController
@RequestMapping("/community/service/problems")
public class ServiceProblemsController extends BaseController
{
    @Autowired
    private IServiceProblemsService serviceProblemsService;

    /**
     * 查询问卷调查列表
     */
    @GetMapping("/list")
    public TableDataInfo list(ServiceProblems serviceProblems)
    {
        startPage();
        List<ServiceProblems> list = serviceProblemsService.selectServiceProblemsList(serviceProblems);
        return getDataTable(list);
    }

    /**
     * 导出问卷调查列表
     */
    @Log(title = "问卷调查", businessType = BusinessType.EXPORT)
    @GetMapping("/export")
    public AjaxResult export(ServiceProblems serviceProblems)
    {
        List<ServiceProblems> list = serviceProblemsService.selectServiceProblemsList(serviceProblems);
        ExcelUtil<ServiceProblems> util = new ExcelUtil<ServiceProblems>(ServiceProblems.class);
        return util.exportExcel(list, "问卷调查数据");
    }

    /**
     * 获取问卷调查详细信息
     */
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return AjaxResult.success(serviceProblemsService.selectServiceProblemsById(id));
    }

    /**
     * 新增问卷调查
     */
    @Log(title = "问卷调查", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody ServiceProblems serviceProblems)
    {
        return toAjax(serviceProblemsService.insertServiceProblems(serviceProblems));
    }

    /**
     * 修改问卷调查
     */
    @Log(title = "问卷调查", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody ServiceProblems serviceProblems)
    {
        return toAjax(serviceProblemsService.updateServiceProblems(serviceProblems));
    }

    /**
     * 删除问卷调查
     */
    @Log(title = "问卷调查", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(serviceProblemsService.deleteServiceProblemsByIds(ids));
    }
}
